package com.eastmoney.emis.edda.domain.valueobject;

/**
 * @description: Description
 * @projectName: EDDA-HSBC
 * @package: com.eastmoney.emis.edda.domain
 * @author: 汪程程
 * @date: 2022/9/27 1:10 PM
 * @version: 1.0
 */
public enum MandateStatus {

    ERROR,
    ACTIVE,
    SUSPENDED,
    DORMANT,
    EXPIRED,
    /**
     * Cancelled via other channels (e.g. personal banking, branch)
     */
    CANCELLED,
    /**
     * DDA becomes obsolete under one of following circumstances:
     * Non-active status housekept after retention period
     * Rejected by payer bank (Only applicable to non-HSBC account)
     */
    DELETED,
    /**
     * Pending from Debtor's bank response (DDAE)
     */
    PDNG,
    /**
     * Pending from Debtor's bank response (EDDA)
     */
    PDFP,
    /**
     * Pending to debtor accounts with HSBC DDA response
     */
    PDOU,

    UNKNOWN;

    public static MandateStatus parse(String status) {
        for (MandateStatus mandateStatus : MandateStatus.values()) {
            if (mandateStatus.name().equals(status)) {
                return mandateStatus;
            }
        }
        return MandateStatus.UNKNOWN;
    }

    public EddaApplyStatus transferToEddaApplyStatus() {
        EddaApplyStatus status = null;
        switch (this) {
            case ACTIVE:
                status = EddaApplyStatus.SUCCESS;
                break;
            case ERROR:
            case DELETED:
            case CANCELLED:
                status = EddaApplyStatus.FAIL;
                break;
        }
        return status;
    }


}
